#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "piledef.h"
/*
struct piledef_s {
    definition* tete;
    piledef* next;
};
*/



piledef* creerPileDef(definition* def)
{
	piledef* p = (piledef*)malloc(sizeof(piledef));
	p->tete = def;
	p->next = NULL;
	return p;
}

piledef* pushPileDef(piledef* pile, definition* def)
{
	piledef* aux = (piledef*)malloc(sizeof(piledef));
	aux->tete = def;
	aux->next = pile;	
	return aux;
}

piledef* popPileDef(piledef* pile)
{

	piledef* aux = pile->next;
	pile->tete = supprimerDefinition(pile->tete);
	free(pile->tete);
	pile->tete = NULL;
	return aux;
}

piledef* supprimerPileDef(piledef* pile)
{		
	while(pile->next)
		pile = popPileDef(pile);
	pile->tete = supprimerDefinition(pile->tete);
	free(pile);
	pile = NULL;
	return pile;
}

int getMaxLevel(piledef* pile)
{
//	printf("pile : %p\n", pile);
	if (pile)		
		return pile->tete->niveau;
	else
		return 0;
}
